﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.Text;
using DomainDriver.DomainModeling.DomainObjects;
using DomainDriver.DomainModeling.StorageManagers.DataSetStorage;
using DomainDriver.DomainModeling.StorageManagers.EntityFrameworkStorage;
using ObjectRow = AutomotivePricingModel.AutomotivePricingDataSet.DriveTrainTypesRow;

namespace AutomotivePricingModel.DriveTrainTypes
{
    public partial class DriveTrainType : IEfEntity<int>, IDataSetSerializable<AutomotivePricingDataSet, DataRow>
    {
        #region ADO .NET Entities Framework Storage

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int EF_Key
        {
            get { return (int)m_Key; }
            set { m_Key = (DriveTrainTypeEnum)value; }
        }

        #endregion

        #region AutomotivePricingDataSet Serialization

        string IDataSetSerializable<AutomotivePricingDataSet, DataRow>.ObjectTableName
        {
            get { return AutomotivePricingDomainModel.SchemaHelper.DriveTrainTypes.TableName; }
        }

        string IDataSetSerializable<AutomotivePricingDataSet, DataRow>.KeyColumnName
        {
            get { return AutomotivePricingDomainModel.SchemaHelper.DriveTrainTypes.EF_DriveTrainTypeIdColumn.ColumnName; }
        }

        void IDataSetSerializable<AutomotivePricingDataSet, DataRow>.Serialize(AutomotivePricingDataSet datasource, DataRow dataRow)
        {
            ObjectRow objectRecord = dataRow as ObjectRow;

            objectRecord.EF_DriveTrainTypeId = (int)m_Key;
            objectRecord.DisplayName = m_DisplayName;
        }

        void IDataSetSerializable<AutomotivePricingDataSet, DataRow>.Deserialize(AutomotivePricingDataSet datasource, DataRow dataRow)
        {
            ObjectRow objectRecord = dataRow as ObjectRow;

            m_Key = (DriveTrainTypeEnum)objectRecord.EF_DriveTrainTypeId;
            m_DisplayName = objectRecord.DisplayName;
        }

        #endregion
    }
}